import { defineStore } from "pinia";

export const useCountStore = defineStore("count", {
    // 数据  - 状态
    state: () => {
        return {
            sum: 10,
            school: "北京航空航天大学abcdefg",
            address: '北京市海淀区学院路37号',
        };
    },
    // 里面放置的是方法，用于响应组件中的“动作”
    actions: {
        increment(value: number) {
            // this是当前的store实例
            this.sum += value;
            console.log('调用了increment方法')
        },
        jian(value: number) {
            this.sum -= value;
            console.log('调用减法')
        }
    },
    getters: {
        bigSum: state => state.sum * 10,
        upperSchool():string {
            return this.school.toUpperCase()
        }
    }
});